#include <iostream>
#include <string>
#include <vector>
using namespace std;

using LL = long long;

#if 0
int main()
{
    int n = 0;
    cin >> n;

    string s;
    s = to_string(n);

    for (auto& e : s)
    {
        int tmp = e - '0';
        e = tmp % 2 ? '1' : '0';
    }
    n = stoi(s);

    cout << n << endl;
}
#endif

#if 0
void Print(const vector<vector<LL>>& vv)
{
    for (auto& v : vv)
    {
        for (auto& e : v)
        {
            cout << e << " ";
        }
        cout << endl;
    }
    cout << endl;
}

int main()
{
    LL n = 0, m = 0;
    scanf("%lld%lld", &n, &m);

    vector<LL> row(n), col(m);
    vector<vector<LL>> v(n, vector<LL>(m));
    auto res = v;

    LL sum = 0, tmp = 0;
    for (int i = 0; i < n; ++i)
    {
        sum = 0;
        for (int j = 0; j < m; ++j)
        {
            scanf("%lld", &tmp);
            v[i][j] = tmp;
            sum += tmp;
        }
        row[i] = sum;
    }

    for (int j = 0; j < m; ++j)
    {
        sum = 0;
        for (int i = 0; i < n; ++i)
        {
            sum += v[i][j];
        }
        col[j] = sum;
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            res[i][j] = row[i] + col[j] - v[i][j];
        }
    }

    Print(res);
}
#endif

void input(vector<int>& v, int n)
{
    for (int i = 0, tmp = 0; i < n; ++i)
    {
        cin >> tmp;
        v[i] = tmp;
    }
}

int main()
{
    int n = 0, k = 0;
    cin >> n >> k;

    vector<int> fgood(n), fbad(n);

    input(fgood, n);
    input(fbad, n);



    return 0;
}